﻿using System;
using System.Drawing;
using System.Windows.Forms;
using PercolationTree.Model;

namespace PercolationTree.Drawing
{
    public partial class DrawingControl : UserControl
    {

        private IDrawable drawable;

        public void setDrawable(IDrawable drawable)
        {
            this.drawable = drawable;
        }

        public DrawingControl()
        {
            InitializeComponent();
            Tree tree = TreeFactory.BuildDeterminedTree(4, 6);
            tree.Percolate(0.0f);
            IDrawable drawable = new DrawableTree(tree);
            this.drawable = drawable;
        }

        public DrawingControl(IDrawable drawable)
        {
            this.drawable = drawable;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            drawable.draw(e);
        }

    }
}
